Here is my code, all objects in both windows are derived from same base class with set tracking area , but I think this issue is not related to tracking area because one of the object always worked, mouseEntered was called on working item and another didn't. The mouse move event just captured by one window and didn't dispatch to another window when leaving current window's area.
private func setupTrackingArea() {
trackingArea = NSTrackingArea.init(rect: bounds, options: [.mouseEnteredAndExited, .activeAlways, .inVisibleRect], owner: self, userInfo: nil)
addTrackingArea(trackingArea)
}
override func mouseEntered(with event: NSEvent) {
isHovered = true
}
Post
Replies
Boosts
Views
Activity
I think the code related to tracking area is not the problem, because I have two buttons, button A is in window A, button B is in window B, the window B is opened by click button A, when I use "show" in segue to open the window B, then button B can't receive mouseEntered event (button A is OK). When I use "modal" to open the window B, then button A can't receive the mouseEntered event (button B is OK).
So I may need to find some way that can make mouseEntered been detected in both windows to fix my problem.
There is a special behavior I forget to mention above, I think my problem caused by the first window was opened by the modal mode.
NSApplication.shared.runModal(for: windowController.window!)
Why I do this is because I need to make back window temporary disable when window A open.
Then when second window, window B may meet following situation:
Open by "modal", then the button B in window B receive mouseEntered event, and button A in window A can't.
Open by "show", then the button A in window A receive mouseEntered event, and button B in window B can't.
If I use
windowController.showWindow(self)
to open window A, then both button can receive mouseEntered event, but the back window is still working.
This isn't what I want.
I am not sure what the correct relation I should set to these three window to achieve I purpose: disable back window and window A and window B can receive mouseEntered event correctly.
I am sorry for the incomplete information to make you confuse.
Eric
I am sorry to post this question after I found the root cause of my problem. This problem caused by the event was captured in a third party code I used, not caused by the system. worksWhenModal setting in NSPanel already provided what I want.
Thanks, I just want to disable the submenu and make the submenu's option gray to avoid user's selection and keep the resize button on. I need this behavior caused by I have to sync other function's behavior in my application that are used NSWindow instead of NSPanel.
I try to subclass NSWindow directly, I found that once I set worksWhenModal to true, then the menu will become available and disable when I set worksWhenModal to false.
Seems the menu item's enable/disable affected directly by the message related setting.
Are there something I can do the testing about this hint?
Thanks~
I have done this by lipo command such as
lipo -create ./dylib_intel/libavcodec.58.dylib ./dylib_arm/libavcodec.58.dylib -output ./dylib_universal/libavcodec.58.dylib
I found the solution.
I can just using xattr -c on my app. Then this issue gone.
Still got the same problem now -_-.....
At last I add additional import in my .mm file to fix this issue. But I don't know why I don't need to do this before Xcode update.
Thanks, got it.
For additional reference, I was building the ffmpeg library for Arm. The Intel part I got from my previous owner directly. I just using the same build config got from the original owner to build the Arm build and using lipo to combine these two library into one to be used in my app. I am wondering are there something I am missing when I build the Arm version. Are there any possible hint to find the solution?
I used otool -l to get some information on my lib. Does anybody know why the load path will be different within the same project?
For Intel:
Load command 11
cmd LC_LOAD_DYLIB
cmdsize 56
name @rpath/libavcodec.58.dylib (offset 24)
time stamp 2 Thu Jan 1 08:00:02 1970
current version 58.54.100
compatibility version 58.0.0
For Arm
Load command 12
cmd LC_LOAD_DYLIB
cmdsize 64
name /usr/local/lib/libavcodec.58.dylib (offset 24)
time stamp 2 Thu Jan 1 08:00:02 1970
current version 58.54.100
compatibility version 58.0.0